/*	
 *				
 *					ISNW ---- It is a war.It is not warcraft!
 *
 *
 *					Author:					zhoukeli(haxixi_keli)
 *					Filename:				dimention2d.h
 *					CreateTime:				2008/12/06
 *					ModifyTime:				2008/12/06
 *
 */

#ifndef __ISNW_DIMENTION_2D_H__
#define __ISNW_DIMENTION_2D_H__

namespace ISNW
{
namespace core
{
	template<typename T>
	class dimention2d
	{
	public:
		//! default constructor
		dimention2d():width(0),height(0){}

		//! constructor with width and height
		dimention2d(const T& w,const T& h)
			:width(w),height(h){}

		//! copy constructor
		dimention2d(const dimention2d<T>& other)
		{
			width = other.width;
			height = other.height;
		}

		//! equality operator
		bool operator == (const dimention2d<T>& other)
		{
			return (width == other.width && height == other.height);
		}

		//! inequality operator
		bool operator != (const dimention2d<T>& other)
		{
			return !(*this == other);
		}

		//! get area
		const T area()
		{
			return (width * height);
		}

		//! set new values
		void set(const T& w,const T& h)
		{
			width = w;
			height = h;
		}

		//! copy operator
		dimention2d<T> operator = (const dimention2d<T>& other)
		{
			width = other.width;
			height = other.height;
			return (*this);
		}

		//! divide width and height by scalar
		dimention2d<T> operator / (const T& scalar) const
		{
			return dimention2d<T>(width/scalar,height/scalar);
		}

		dimention2d<T> operator /= (const T& scalor)
		{
			width /= scalor;
			height /= scalor;
			return (*this);
		}

		//! multiply width and height by scalar
		dimention2d<T> operator * (const T& scalar) const
		{
			return dimention2d<T>(width*scalar,height*scalar);
		}

		dimention2d<T> operator *= (const T& scalar)
		{
			width *= scalar;
			height *= scalar;
			return (*this);
		}

	public:
		T width;
		T height;
	};

	//! typedef for an f32 dimension.
	typedef dimention2d<f32> dimention2df;

	//! typedef for an s32 dimension.
	typedef dimention2d<s32> dimention2di;

} // end namespace ISNW
} // end namespace core
#endif